﻿
#include <Windows.h>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <time.h>
#include <stdio.h>
#include <sstream>
#include <iostream>
#include <iostream>
#include <stdarg.h> 
#include <cstdint>

using namespace std;

#include <capstone/include/capstone/capstone.h>
#include <enma_pe/enma_pe/enma_pe.h>
#include <fukutasm/fukutasm/fukutasm.h>
#include <furikuri/furikuri.h>



#include "lzo1z.h"

typedef int(__cdecl* _depack_algo)(const unsigned char* src, unsigned long  src_len, unsigned char* dst, unsigned long* dst_len, void* wrkmem);

unsigned char lzo_depack_32[] = {//0xCC,
    0x55, 0x8B, 0xEC, 0x8B, 0x55, 0x08, 0x8B, 0x45, 0x14, 0x01, 0x55, 0x0C, 0x53, 0x33, 0xDB, 0x56,
    0x57, 0x8B, 0x7D, 0x10, 0x89, 0x18, 0x8A, 0x02, 0x89, 0x5D, 0x08, 0x6A, 0x04, 0x5B, 0x3C, 0x11,
    0x76, 0x1C, 0x0F, 0xB6, 0xC8, 0x83, 0xE9, 0x11, 0x42, 0x3B, 0xCB, 0x0F, 0x82, 0xF6, 0x01, 0x00,
    0x00, 0x8A, 0x02, 0x88, 0x07, 0x47, 0x42, 0x83, 0xE9, 0x01, 0x75, 0xF5, 0xEB, 0x63, 0x0F, 0xB6,
    0x32, 0x42, 0x83, 0xFE, 0x10, 0x0F, 0x83, 0x90, 0x00, 0x00, 0x00, 0x85, 0xF6, 0x75, 0x17, 0xEB,
    0x07, 0x81, 0xC6, 0xFF, 0x00, 0x00, 0x00, 0x42, 0x80, 0x3A, 0x00, 0x74, 0xF4, 0x0F, 0xB6, 0x02,
    0x83, 0xC6, 0x0F, 0x03, 0xF0, 0x42, 0x8B, 0x02, 0x03, 0xD3, 0x89, 0x07, 0x03, 0xFB, 0x83, 0xEE,
    0x01, 0x74, 0x2E, 0x3B, 0xF3, 0x72, 0x1F, 0x8B, 0x02, 0x2B, 0xF3, 0x89, 0x07, 0x03, 0xD3, 0x03,
    0xFB, 0x3B, 0xF3, 0x73, 0xF2, 0x85, 0xF6, 0x74, 0x18, 0x8A, 0x02, 0x88, 0x07, 0x47, 0x42, 0x83,
    0xEE, 0x01, 0x75, 0xF5, 0xEB, 0x0B, 0x8A, 0x02, 0x88, 0x07, 0x47, 0x42, 0x83, 0xEE, 0x01, 0x75,
    0xF5, 0x0F, 0xB6, 0x32, 0x42, 0x83, 0xFE, 0x10, 0x73, 0x31, 0x0F, 0xB6, 0x02, 0x8B, 0xCF, 0xC1,
    0xE6, 0x06, 0xC1, 0xE8, 0x02, 0x8D, 0x9E, 0x01, 0x07, 0x00, 0x00, 0x03, 0xD8, 0x42, 0x2B, 0xCB,
    0x89, 0x5D, 0x08, 0x8A, 0x01, 0x88, 0x07, 0x8A, 0x41, 0x01, 0x88, 0x47, 0x01, 0x8A, 0x41, 0x02,
    0x88, 0x47, 0x02, 0x83, 0xC7, 0x03, 0xE9, 0x43, 0x01, 0x00, 0x00, 0x83, 0xFE, 0x40, 0x72, 0x47,
    0x8B, 0xCE, 0x8B, 0xDF, 0x83, 0xE1, 0x1F, 0x83, 0xF9, 0x1C, 0x72, 0x05, 0x2B, 0x5D, 0x08, 0xEB,
    0x12, 0x0F, 0xB6, 0x02, 0xC1, 0xE8, 0x02, 0xC1, 0xE1, 0x06, 0x40, 0x03, 0xC1, 0x42, 0x89, 0x45,
    0x08, 0x2B, 0xD8, 0xC1, 0xEE, 0x05, 0x4E, 0x8A, 0x03, 0x88, 0x07, 0x8A, 0x43, 0x01, 0x88, 0x47,
    0x01, 0x83, 0xC7, 0x02, 0x83, 0xC3, 0x02, 0x8A, 0x03, 0x88, 0x07, 0x47, 0x43, 0x83, 0xEE, 0x01,
    0x75, 0xF5, 0xE9, 0xF7, 0x00, 0x00, 0x00, 0x83, 0xFE, 0x20, 0x72, 0x35, 0x83, 0xE6, 0x1F, 0x75,
    0x17, 0xEB, 0x07, 0x81, 0xC6, 0xFF, 0x00, 0x00, 0x00, 0x42, 0x80, 0x3A, 0x00, 0x74, 0xF4, 0x0F,
    0xB6, 0x02, 0x83, 0xC6, 0x1F, 0x03, 0xF0, 0x42, 0x0F, 0xB6, 0x02, 0x8B, 0xDF, 0x0F, 0xB6, 0x4A,
    0x01, 0xC1, 0xE0, 0x06, 0xC1, 0xE9, 0x02, 0x40, 0x03, 0xC1, 0x2B, 0xD8, 0x83, 0xC2, 0x02, 0xEB,
    0x57, 0x83, 0xFE, 0x10, 0x0F, 0x82, 0x93, 0x00, 0x00, 0x00, 0x8B, 0xC6, 0x8B, 0xDF, 0x83, 0xE0,
    0x08, 0xC1, 0xE0, 0x0B, 0x2B, 0xD8, 0x83, 0xE6, 0x07, 0x75, 0x17, 0xEB, 0x07, 0x81, 0xC6, 0xFF,
    0x00, 0x00, 0x00, 0x42, 0x80, 0x3A, 0x00, 0x74, 0xF4, 0x0F, 0xB6, 0x02, 0x83, 0xC6, 0x07, 0x03,
    0xF0, 0x42, 0x0F, 0xB6, 0x4A, 0x01, 0x0F, 0xB6, 0x02, 0x83, 0xC2, 0x02, 0xC1, 0xE9, 0x02, 0xC1,
    0xE0, 0x06, 0x03, 0xC8, 0x2B, 0xD9, 0x3B, 0xDF, 0x0F, 0x84, 0xA6, 0x00, 0x00, 0x00, 0x81, 0xEB,
    0x00, 0x40, 0x00, 0x00, 0x8B, 0xC7, 0x2B, 0xC3, 0x89, 0x45, 0x08, 0x83, 0xFE, 0x06, 0x0F, 0x82,
    0x43, 0xFF, 0xFF, 0xFF, 0x8B, 0xC7, 0x6A, 0x04, 0x2B, 0xC3, 0x59, 0x3B, 0xC1, 0x0F, 0x8C, 0x34,
    0xFF, 0xFF, 0xFF, 0x8B, 0x03, 0x03, 0xD9, 0x89, 0x07, 0x03, 0xF9, 0x83, 0xEE, 0x02, 0x8B, 0x03,
    0x2B, 0xF1, 0x89, 0x07, 0x03, 0xD9, 0x03, 0xF9, 0x3B, 0xF1, 0x73, 0xF2, 0x85, 0xF6, 0x74, 0x2E,
    0x8A, 0x03, 0x88, 0x07, 0x47, 0x43, 0x83, 0xEE, 0x01, 0x75, 0xF5, 0xEB, 0x21, 0x0F, 0xB6, 0x02,
    0x8B, 0xCF, 0xC1, 0xE8, 0x02, 0x40, 0xC1, 0xE6, 0x06, 0x03, 0xC6, 0x42, 0x2B, 0xC8, 0x89, 0x45,
    0x08, 0x8A, 0x01, 0x88, 0x07, 0x8A, 0x41, 0x01, 0x88, 0x47, 0x01, 0x83, 0xC7, 0x02, 0x0F, 0xB6,
    0x4A, 0xFF, 0x83, 0xE1, 0x03, 0x74, 0x25, 0x8A, 0x02, 0x88, 0x07, 0x47, 0x42, 0x83, 0xF9, 0x01,
    0x76, 0x11, 0x8A, 0x02, 0x88, 0x07, 0x47, 0x42, 0x83, 0xF9, 0x02, 0x76, 0x06, 0x8A, 0x02, 0x88,
    0x07, 0x47, 0x42, 0x0F, 0xB6, 0x32, 0x42, 0xE9, 0x8F, 0xFE, 0xFF, 0xFF, 0x6A, 0x04, 0x5B, 0xE9,
    0xEA, 0xFD, 0xFF, 0xFF, 0x2B, 0x7D, 0x10, 0x8B, 0x45, 0x14, 0x3B, 0x55, 0x0C, 0x89, 0x38, 0x1B,
    0xC0, 0x83, 0xE0, 0xFC, 0x33, 0xF6, 0x83, 0xC0, 0xFC, 0x3B, 0x55, 0x0C, 0x5F, 0x0F, 0x44, 0xC6,
    0x5E, 0x5B, 0x5D, 0xC3
};

unsigned char lzo_depack_64[963] = {
    0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x74, 0x24, 0x10, 0x48, 0x89, 0x7C, 0x24, 0x18, 0x33,
    0xDB, 0x48, 0x8D, 0x3C, 0x11, 0x49, 0x89, 0x19, 0x49, 0x8B, 0xF0, 0x0F, 0xB6, 0x01, 0x4C, 0x8B,
    0xD1, 0x4D, 0x8B, 0xD8, 0x3C, 0x11, 0x76, 0x30, 0x0F, 0xB6, 0xC8, 0x48, 0x83, 0xE9, 0x11, 0x49,
    0xFF, 0xC2, 0x48, 0x83, 0xF9, 0x04, 0x0F, 0x82, 0x05, 0x03, 0x00, 0x00, 0x0F, 0x1F, 0x40, 0x00,
    0x41, 0x0F, 0xB6, 0x02, 0x49, 0xFF, 0xC2, 0x41, 0x88, 0x03, 0x49, 0xFF, 0xC3, 0x48, 0x83, 0xE9,
    0x01, 0x75, 0xED, 0xE9, 0xB7, 0x00, 0x00, 0x00, 0x0F, 0xB6, 0xC0, 0x49, 0xFF, 0xC2, 0x48, 0x83,
    0xF8, 0x10, 0x0F, 0x83, 0xF0, 0x00, 0x00, 0x00, 0x48, 0x85, 0xC0, 0x75, 0x30, 0x41, 0x0F, 0xB6,
    0x0A, 0x84, 0xC9, 0x75, 0x1D, 0x66, 0x66, 0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x41, 0x0F, 0xB6, 0x4A, 0x01, 0x49, 0xFF, 0xC2, 0x48, 0x05, 0xFF, 0x00, 0x00, 0x00, 0x84, 0xC9,
    0x74, 0xEE, 0x0F, 0xB6, 0xC9, 0x49, 0xFF, 0xC2, 0x48, 0x8D, 0x44, 0x08, 0x0F, 0x48, 0x83, 0xC0,
    0x03, 0x48, 0x83, 0xF8, 0x08, 0x72, 0x18, 0x49, 0x8B, 0x0A, 0x48, 0x83, 0xE8, 0x08, 0x49, 0x89,
    0x0B, 0x49, 0x83, 0xC2, 0x08, 0x49, 0x83, 0xC3, 0x08, 0x48, 0x83, 0xF8, 0x08, 0x73, 0xE8, 0x48,
    0x83, 0xF8, 0x04, 0x72, 0x12, 0x41, 0x8B, 0x0A, 0x49, 0x83, 0xC2, 0x04, 0x41, 0x89, 0x0B, 0x49,
    0x83, 0xC3, 0x04, 0x48, 0x83, 0xE8, 0x04, 0x48, 0x85, 0xC0, 0x74, 0x33, 0x41, 0x0F, 0xB6, 0x0A,
    0x49, 0xFF, 0xC2, 0x41, 0x88, 0x0B, 0x49, 0xFF, 0xC3, 0x48, 0x83, 0xF8, 0x01, 0x76, 0x20, 0x41,
    0x0F, 0xB6, 0x0A, 0x49, 0xFF, 0xC2, 0x41, 0x88, 0x0B, 0x49, 0xFF, 0xC3, 0x48, 0x83, 0xF8, 0x02,
    0x76, 0x0D, 0x41, 0x0F, 0xB6, 0x02, 0x41, 0x88, 0x03, 0x49, 0xFF, 0xC3, 0x49, 0xFF, 0xC2, 0x41,
    0x0F, 0xB6, 0x02, 0x49, 0xFF, 0xC2, 0x48, 0x83, 0xF8, 0x10, 0x73, 0x3C, 0x41, 0x0F, 0xB6, 0x0A,
    0x49, 0xFF, 0xC2, 0x48, 0xC1, 0xE0, 0x06, 0x48, 0xC1, 0xE9, 0x02, 0x48, 0x8D, 0x9C, 0x01, 0x01,
    0x07, 0x00, 0x00, 0x49, 0x8B, 0xCB, 0x48, 0x2B, 0xCB, 0x0F, 0xB6, 0x01, 0x41, 0x88, 0x03, 0x0F,
    0xB6, 0x41, 0x01, 0x41, 0x88, 0x43, 0x01, 0x0F, 0xB6, 0x41, 0x02, 0x41, 0x88, 0x43, 0x02, 0x49,
    0x83, 0xC3, 0x03, 0xE9, 0xDF, 0x01, 0x00, 0x00, 0x48, 0x83, 0xF8, 0x40, 0x72, 0x5E, 0x48, 0x8B,
    0xD0, 0x4D, 0x8B, 0xC3, 0x83, 0xE2, 0x1F, 0x48, 0x83, 0xFA, 0x1C, 0x73, 0x14, 0x41, 0x0F, 0xB6,
    0x0A, 0x48, 0xC1, 0xE9, 0x02, 0x48, 0xC1, 0xE2, 0x06, 0x49, 0xFF, 0xC2, 0x48, 0x8D, 0x5C, 0x11,
    0x01, 0x4C, 0x2B, 0xC3, 0x48, 0xC1, 0xE8, 0x05, 0x48, 0xFF, 0xC8, 0x41, 0x0F, 0xB6, 0x08, 0x41,
    0x88, 0x0B, 0x41, 0x0F, 0xB6, 0x48, 0x01, 0x41, 0x88, 0x4B, 0x01, 0x49, 0x83, 0xC3, 0x02, 0x49,
    0x83, 0xC0, 0x02, 0x41, 0x0F, 0xB6, 0x08, 0x4D, 0x8D, 0x40, 0x01, 0x41, 0x88, 0x0B, 0x49, 0xFF,
    0xC3, 0x48, 0x83, 0xE8, 0x01, 0x75, 0xEC, 0xE9, 0x7B, 0x01, 0x00, 0x00, 0x48, 0x83, 0xF8, 0x20,
    0x72, 0x5A, 0x83, 0xE0, 0x1F, 0x75, 0x36, 0x41, 0x0F, 0xB6, 0x0A, 0x84, 0xC9, 0x75, 0x23, 0x0F,
    0x1F, 0x40, 0x00, 0x66, 0x66, 0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x90,
    0x41, 0x0F, 0xB6, 0x4A, 0x01, 0x49, 0xFF, 0xC2, 0x48, 0x05, 0xFF, 0x00, 0x00, 0x00, 0x84, 0xC9,
    0x74, 0xEE, 0x0F, 0xB6, 0xC9, 0x49, 0xFF, 0xC2, 0x48, 0x8D, 0x44, 0x08, 0x1F, 0x41, 0x0F, 0xB6,
    0x52, 0x01, 0x4D, 0x8B, 0xC3, 0x41, 0x0F, 0xB6, 0x0A, 0xC1, 0xEA, 0x02, 0xC1, 0xE1, 0x06, 0x8D,
    0x5C, 0x0A, 0x01, 0x4C, 0x2B, 0xC3, 0x49, 0x83, 0xC2, 0x02, 0xEB, 0x72, 0x48, 0x83, 0xF8, 0x10,
    0x0F, 0x82, 0xE5, 0x00, 0x00, 0x00, 0x48, 0x8B, 0xC8, 0x4D, 0x8B, 0xC3, 0x83, 0xE1, 0x08, 0x48,
    0xC1, 0xE1, 0x0B, 0x4C, 0x2B, 0xC1, 0x83, 0xE0, 0x07, 0x75, 0x25, 0x41, 0x0F, 0xB6, 0x0A, 0x84,
    0xC9, 0x75, 0x12, 0x41, 0x0F, 0xB6, 0x4A, 0x01, 0x49, 0xFF, 0xC2, 0x48, 0x05, 0xFF, 0x00, 0x00,
    0x00, 0x84, 0xC9, 0x74, 0xEE, 0x0F, 0xB6, 0xC9, 0x49, 0xFF, 0xC2, 0x48, 0x8D, 0x44, 0x08, 0x07,
    0x41, 0x0F, 0xB6, 0x0A, 0x41, 0x0F, 0xB6, 0x52, 0x01, 0x49, 0x83, 0xC2, 0x02, 0xC1, 0xE1, 0x06,
    0xC1, 0xEA, 0x02, 0x03, 0xCA, 0x4C, 0x2B, 0xC1, 0x4D, 0x3B, 0xC3, 0x0F, 0x84, 0x08, 0x01, 0x00,
    0x00, 0x49, 0x81, 0xE8, 0x00, 0x40, 0x00, 0x00, 0x49, 0x8B, 0xDB, 0x49, 0x2B, 0xD8, 0x49, 0x8B,
    0xCB, 0x49, 0x2B, 0xC8, 0x48, 0x83, 0xF9, 0x08, 0x0F, 0x8C, 0xED, 0xFE, 0xFF, 0xFF, 0x48, 0x83,
    0xC0, 0x02, 0x48, 0x83, 0xF8, 0x08, 0x72, 0x18, 0x49, 0x8B, 0x08, 0x48, 0x83, 0xE8, 0x08, 0x49,
    0x89, 0x0B, 0x49, 0x83, 0xC0, 0x08, 0x49, 0x83, 0xC3, 0x08, 0x48, 0x83, 0xF8, 0x08, 0x73, 0xE8,
    0x48, 0x83, 0xF8, 0x04, 0x72, 0x12, 0x41, 0x8B, 0x08, 0x49, 0x83, 0xC0, 0x04, 0x41, 0x89, 0x0B,
    0x49, 0x83, 0xC3, 0x04, 0x48, 0x83, 0xE8, 0x04, 0x48, 0x85, 0xC0, 0x74, 0x5A, 0x41, 0x0F, 0xB6,
    0x08, 0x41, 0x88, 0x0B, 0x49, 0xFF, 0xC3, 0x48, 0x83, 0xF8, 0x01, 0x76, 0x4A, 0x41, 0x0F, 0xB6,
    0x48, 0x01, 0x41, 0x88, 0x0B, 0x49, 0xFF, 0xC3, 0x48, 0x83, 0xF8, 0x02, 0x76, 0x39, 0x41, 0x0F,
    0xB6, 0x40, 0x02, 0x41, 0x88, 0x03, 0x49, 0xFF, 0xC3, 0xEB, 0x2C, 0x41, 0x0F, 0xB6, 0x0A, 0x49,
    0xFF, 0xC2, 0x48, 0xC1, 0xE9, 0x02, 0x48, 0xC1, 0xE0, 0x06, 0x48, 0x8D, 0x5C, 0x01, 0x01, 0x49,
    0x8B, 0xCB, 0x48, 0x2B, 0xCB, 0x0F, 0xB6, 0x01, 0x41, 0x88, 0x03, 0x0F, 0xB6, 0x41, 0x01, 0x41,
    0x88, 0x43, 0x01, 0x49, 0x83, 0xC3, 0x02, 0x41, 0x0F, 0xB6, 0x4A, 0xFF, 0x83, 0xE1, 0x03, 0x74,
    0x3F, 0x41, 0x0F, 0xB6, 0x02, 0x49, 0xFF, 0xC2, 0x41, 0x88, 0x03, 0x49, 0xFF, 0xC3, 0x48, 0x83,
    0xF9, 0x01, 0x76, 0x20, 0x41, 0x0F, 0xB6, 0x02, 0x49, 0xFF, 0xC2, 0x41, 0x88, 0x03, 0x49, 0xFF,
    0xC3, 0x48, 0x83, 0xF9, 0x02, 0x76, 0x0D, 0x41, 0x0F, 0xB6, 0x02, 0x41, 0x88, 0x03, 0x49, 0xFF,
    0xC3, 0x49, 0xFF, 0xC2, 0x41, 0x0F, 0xB6, 0x02, 0x49, 0xFF, 0xC2, 0xE9, 0xD8, 0xFD, 0xFF, 0xFF,
    0x41, 0x0F, 0xB6, 0x02, 0xE9, 0xCF, 0xFC, 0xFF, 0xFF, 0x4C, 0x2B, 0xDE, 0x4D, 0x89, 0x19, 0x4C,
    0x3B, 0xD7, 0x75, 0x12, 0x33, 0xC0, 0x48, 0x8B, 0x5C, 0x24, 0x08, 0x48, 0x8B, 0x74, 0x24, 0x10,
    0x48, 0x8B, 0x7C, 0x24, 0x18, 0xC3, 0x48, 0x8B, 0x5C, 0x24, 0x08, 0xB8, 0xFC, 0xFF, 0xFF, 0xFF,
    0x48, 0x8B, 0x74, 0x24, 0x10, 0xB9, 0xF8, 0xFF, 0xFF, 0xFF, 0x48, 0x8B, 0x7C, 0x24, 0x18, 0x0F,
    0x42, 0xC1, 0xC3
};

#ifdef _M_X64

#ifdef _DEBUG 
#pragma comment(lib,"lzo2_mdd64.lib")
#else
#pragma comment(lib,"lzo2_mt64.lib")
#endif

#else

#ifdef _DEBUG 
#pragma comment(lib,"lzo2_mdd32.lib")
#else
#pragma comment(lib,"lzo2_mt32.lib")
#endif

#endif


const char test_message[] = "This is test message what passed through compression and decompression!!!";

int main() {

    bool allowed_relocs = true;

    unsigned long totaly_data_size = sizeof(test_message);
    lzo_uint packed_size = 0;


    uint8_t* compressed_buf = new uint8_t[totaly_data_size + (totaly_data_size / 16) + 64 + 3];
    
    {
        void* work_mem = new uint8_t[LZO1Z_999_MEM_COMPRESS];


        if (lzo1z_999_compress((const unsigned char*)test_message, totaly_data_size, 
            compressed_buf, &packed_size, work_mem) != LZO_E_OK) {

            delete[] work_mem;
            delete[] compressed_buf;
            return 0;
        }

        delete[] work_mem;
    }

    fuku_code_holder code_holder;
    fuku_code_analyzer anal_code;

#ifdef _M_X64
    fuku_code_profiler code_profiler(FUKU_ASSAMBLER_ARCH_X64);
    anal_code.set_arch(fuku_assambler_arch::FUKU_ASSAMBLER_ARCH_X64);
    anal_code.analyze_code(code_holder, lzo_depack_64, sizeof(lzo_depack_64), 0, 0);

#else
    fuku_code_profiler code_profiler(FUKU_ASSAMBLER_ARCH_X86);
    anal_code.set_arch(fuku_assambler_arch::FUKU_ASSAMBLER_ARCH_X86);
    anal_code.analyze_code(code_holder, lzo_depack_32, sizeof(lzo_depack_32), 0, 0);

#endif

    code_profiler.profile_code(code_holder);


    fuku_code_analyzer ob_anal_code = code_holder;

    fuku_obfuscator obfuscator;


    fuku_settings_obfuscation ob_set(3, 3, 30.f, 30.f, 30.f,
        FUKU_ASM_SHORT_CFG_USE_EAX_SHORT | FUKU_ASM_SHORT_CFG_USE_DISP_SHORT | FUKU_ASM_SHORT_CFG_USE_IMM_SHORT, false, !allowed_relocs);

    obfuscator.set_destination_virtual_address(0);
    obfuscator.set_settings(ob_set);
    obfuscator.set_code(&ob_anal_code.get_code());

    uint32_t s_time = GetTickCount();

    obfuscator.obfuscate_code();

    std::map<uint64_t, uint64_t> associations;
    std::vector<fuku_image_relocation> relocations;

    ob_anal_code.get_code().finalize_code(&associations, &relocations);

    std::vector<uint8_t> shell_code_result = ob_anal_code.get_code().dump_code();

    printf("shellcode obfuscated in %.4f sec | size scale %.2f | %.3f MIB \n",
        (GetTickCount() - s_time) / 1000.f, (float)shell_code_result.size() / sizeof(lzo_depack_32),
        (float)shell_code_result.size() / (float)(1024 * 1024));

    uint8_t* shell_code_result_ptr = shell_code_result.data();

    { //make page executable

        DWORD old_p;
        VirtualProtect(shell_code_result_ptr, shell_code_result.size(), PAGE_EXECUTE_READWRITE, &old_p);
    }

    _depack_algo depack = (_depack_algo)(shell_code_result_ptr + associations.begin()->second);

    if(allowed_relocs) { //fix relocs if allowed

#ifdef _M_X64
        for (auto& rel : relocations) {
            *(uint64_t*)& shell_code_result_ptr[rel.virtual_address] += (uint64_t)shell_code_result_ptr;
        }
#else
        for (auto& rel : relocations) {
            *(uint32_t*)& shell_code_result_ptr[rel.virtual_address] += (uint32_t)shell_code_result_ptr;
        }
#endif

    }


    char* decompressed_message = new char[totaly_data_size];

    depack(compressed_buf, packed_size, 
        (unsigned char*)decompressed_message, &totaly_data_size, 0);


    printf("%s\n", decompressed_message);

    delete decompressed_message;
    delete compressed_buf;


    return 0;
}